package com.sz.biz.common.base.service.impl;

import com.sz.biz.common.base.entity.MessageTemplate;
import com.sz.biz.common.base.service.MessageTemplateService;
import com.sz.common.base.dao.ParamData;
import com.sz.common.base.service.AbstractService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Function: TODO: ADD FUNCTION <br>
 * Author: Johnboy <br>
 * Date: 2017-08-10 15:00:00
 */
@Service
public class MessageTemplateServiceImpl extends AbstractService implements MessageTemplateService {

    @Override
    protected String getMapperNamespace() {
        return "com.sz.biz.common.base.entity.MessageTemplateMapper";
    }

    @Override
    public MessageTemplate findById(int id) {
        return (MessageTemplate) this.dao.findForObject(this.getSqlName("selectByPrimaryKey"), id);
    }

    @Override
    public List<MessageTemplate> findByRefParentId(int refParentId) {
        List<MessageTemplate> list = this.dao.findForList(this.getSqlName("selectByRefParentId"), refParentId, MessageTemplate.class);
        return list;
    }

    @Override
    public List<MessageTemplate> findByTemplateType(String templateType) {
        List<MessageTemplate> list = this.dao.findForList(this.getSqlName("selectByTemplateType"), templateType, MessageTemplate.class);
        return list;
    }

    @Override
    public MessageTemplate findByTemplateTypeAndRefParendId(String templateType, int refParentId) {
        ParamData pd = new ParamData();
        pd.put("templateType",templateType);
        pd.put("refParentId",refParentId);
        return (MessageTemplate) this.dao.findForObject(this.getSqlName("selectByTemplateTypeAndRefParentId"),pd);
    }
}
